package algorithm.view.maze.generation;
/**
 * @author bingo
 * @Description
 * @Date 2018/6/9
 */
public class MazeData {

    public static   char  WALL='#';

    public static   char  RODE =' ';

    public char[][] data;

    private int entranceX,entranceY;

    private int exitX,exitY;

    public boolean[][] visited;

    public boolean[][] mist;

   /**l是行 ，m是列*/
   private int  l,m;



    public MazeData(int l, int m) {
        data = new char[l][m];
        this.l = l;
        this.m = m;
        visited = new boolean[l][m];
        mist    = new boolean[l][m];
        entranceX = 1;
        entranceY = 0;
        exitX = l-2;
        exitY = m-1;
        for(int i=0;i<l;i++){
            for(int j=0;j<m;j++){
                 if(i%2==1 && j%2==1){
                      data[i][j] = RODE;
                 }else {
                      data[i][j] = WALL;
                 }
                 visited[i][j] =false;
                 mist[i][j] = true;
              }
        }
        data[entranceX][entranceY]  = RODE ;
        data[exitX][exitY] = RODE;
    }

    public int getEntranceX() {
        return entranceX;
    }

    public int getEntranceY() {
        return entranceY;
    }

    public int getExitX() {
        return exitX;
    }

    public int getExitY() {
        return exitY;
    }

    public int getL() {
        return l;
    }

    public int getM() {
        return m;
    }

    public char[][] getData() {
        return data;
    }

    public boolean inArea(int x,int y){

        return  x >= 0 && x < l && y >= 0 && y < m;

    }

    public void opMist(int newX, int newY) {

        for(int i= newX-1;i<=(newX+1); i++ ){
            for(int j=newY-1;j<=(newY+1);j++){
                if(inArea(i,j)){
                  mist[i][j] = false;
                }

            }

        }
    }
}
